<template>
  <div class="">
    <el-dialog title="提交手续" :visible.sync="dialogBoole" width="500px">
      <el-form :model="form" ref="form" :rules="rules" label-width="90px" class="demo-form-inline">
        <el-form-item label="附件:" prop="proceduresAttachmentOss">
          <image-common v-model="form.proceduresAttachmentOss" :limit="5" :disabled="false" :upType="2"/>
        </el-form-item>
        <el-form-item label="说明:" prop="proceduresRemark">
          <el-input type="textarea" v-model="form.proceduresRemark" placeholder="请输入说明"
                    :rows="6" maxlength="500" show-word-limit/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleSubmit(1)">取 消</el-button>
        <el-button type="primary" @click="handleSubmit(2)">确 定</el-button>
      </div>


    </el-dialog>
  </div>
</template>

<script>
import {submitProcedures} from "@/api/vehicleDisposal/routineHandle.js"

export default {
  name: 'submitProcedure',//提交手续
  computed: {},
  watch: {},
  data() {
    return {
      form: {
        proceduresAttachmentOss: '',
        vehicleDisposalId: null,
        vehicleDisposalNo: null
      },
      dialogBoole: false,
      rules: {
        proceduresAttachmentOss: [
          {required: true, message: '请上传附件', trigger: 'blur'}
        ]
      }
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    handleOpen(row) {
      this.form.vehicleDisposalId = row.vehicleDisposalId
      this.form.vehicleDisposalNo = row.vehicleDisposalNo
      this.dialogBoole = true
    },

    handleSubmit(val) {
      if (val === 1) {
        this.form = {
          proceduresAttachmentOss: '',
          vehicleDisposalId: null,
          vehicleDisposalNo: null
        }
        this.$refs.form.resetFields();
        this.dialogBoole = false
      }

      if (val === 2) {
        this.$refs.form.validate((valid) => {
          if (valid) {
            submitProcedures(this.form).then(res => {
              if (res.code === 200) {
                this.$message.success('操作成功')
                this.dialogBoole = false
                this.$emit('refresh')
              }
            })
          }
        });
      }
    }

  },
}
</script>

<style scoped lang="scss">
</style>
